package com.qf.controller;

import com.qf.entity.User;
import com.qf.service.UserService;
import com.qf.service.impl.userServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/*
杨威
2021/9/24
14:24
*/
@WebServlet("/updatePwd")
public class UpdatePwdController extends HttpServlet {
    UserService userService=new userServiceImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String newPwd = request.getParameter("newPwd");
        User user = (User)request.getSession().getAttribute("user");
        String userName = user.getUserName();
        int i = userService.updatePassWord(userName, newPwd);
        PrintWriter writer = response.getWriter();
        writer.println(i);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
